<template>
  <div class="notes_box" id="notesPoin">
    <div class="form_title">注解</div>
    <div>
      <el-checkbox v-model="checked">@dist</el-checkbox>
    </div>
    <!-- @dist -->
    <DistInput v-model="form" v-if="checked"></DistInput>
    <!-- 自定义注释 -->
    <CustomAnnotation :items="treeItems" ref="stream_customAnnotation" />
  </div>
</template>

<script>
import CustomAnnotation from "@/views/edge/CommonComponents/CustomAnnotation";
import DistInput from "@/components/DistInput";
import {
  parseTreeJson,
  parseJson,
  reverseJson,
  verificationTree,
} from "@/utils/index";
export default {
  components: { DistInput, CustomAnnotation },
  data() {
    return {
      checked: false,
      treeItems: [],
      form: {
        execGroup: "",
        parallel: "",
        checkedImplement: false,
        checkedParallel: false,
      },
    };
  },
  methods: {
    getNotes() {
      let target = {};
      target.annotationList = [];
      target.asyncAnnotation = this.asyncAnnotation; //是否async (数据源)
      target.annotationListObjects = [];
      target.treeData = this.$refs.stream_customAnnotation.items; //树形结构的原始数据,回显使用
      let items = this.$refs.stream_customAnnotation.items;
      // 是否选中
      target.distChecked = this.checked;
      //注释的树形结构转换
      target.annotationList = parseTreeJson(items);
      //注释的树形结构转换第二种格式
      target.annotationListObjects = parseJson(items);
      target.form = this.form;
      // @dist 数据整理
      if (this.checked) {
        const asyncStr = `@dist(execGroup='${this.form.execGroup}' ,parallel='${this.form.parallel}')`;
        target.annotationList.unshift(asyncStr);
        target.annotationListObjects.unshift({
          elements: [
            {
              key: "execGroup",
              value: this.form.execGroup,
            },
            {
              key: "parallel",
              value: this.form.parallel,
            },
          ],
          annotations: [],
          name: "dist",
        });
      }
      target.annotationList = target.annotationList.filter((item) => {
        return item !== "";
      });
      return target;
    },
  },
};
</script>

<style lang='scss' scoped>
.notes_box {
  /* margin-top: 20px; */
}
</style>